package cc.mrbird.charging.service.impl;

import cc.mrbird.charging.dao.ChargingMapper;
import cc.mrbird.charging.domain.Charging;
import cc.mrbird.charging.service.ChargingService;
import cc.mrbird.submission.domain.PullDown;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargingServiceImpl implements ChargingService {
    @Autowired
    private ChargingMapper chargingMapper;

    @Override
    public void saveCharging(Charging charging) {
        chargingMapper.saveCharging(charging);
    }

    @Override
    public String findId() {
        return chargingMapper.findId();
    }

    @Override
    public List<PullDown> FindPullDown(PullDown pullDown) {
        return chargingMapper.FindPullDown(pullDown);
    }

    @Override
    public List<Charging> getChargingList(Charging charging) {
        return chargingMapper.getChargingList(charging);
    }

    @Override
    public PullDown savePullDown(PullDown pullDown) {
        return chargingMapper.savePullDown(pullDown);
    }

    @Override
    public void addPullDown(PullDown pullDown) {
        chargingMapper.addPullDown(pullDown);
    }

    @Override
    public Charging getChargingId(Charging charging) {
        List<Charging> list = chargingMapper.getChargingList(charging);
        if (list == null || list.size()==0){
            return null;
        }
        for(Charging charging1:list){
            String processingResults = charging1.getProcessingResults();
            if(processingResults == null){
                charging1.setProcessingResults("");
            }
            String complaintType = charging1.getComplaintType();
            if(complaintType == null){
                charging1.setComplaintType("");
            }
            String handler = charging1.getHandler();
            if(handler == null){
                charging1.setHandler("");
            }
            String processing = charging1.getProcessing();
            if(processing == null){
                charging1.setProcessing("");
            }
            String paymentChannels = charging1.getPaymentChannels();
            if(paymentChannels == null){
                charging1.setPaymentChannels("");
            }
            String complaintChannels = charging1.getComplaintChannels();
            if(complaintChannels == null){
                charging1.setComplaintChannels("");
            }
            String contactInformation = charging1.getContactInformation();
            if(contactInformation == null){
                charging1.setContactInformation("");
            }
            String registrar = charging1.getRegistrar();
            if(registrar == null){
                charging1.setRegistrar("");
            }
            String remakes = charging1.getRemakes();
            if(remakes == null){
                charging1.setRemakes("");
            }
        }
        return list.get(0);
    }

    @Override
    public void updateCharging(Charging charging) {
        chargingMapper.updateCharging(charging);
    }

    @Override
    public void cancelCharging(Charging charging) {
        chargingMapper.cancelCharging(charging);
    }

    @Override
    public String sumFirst() {
        return chargingMapper.sumFirst();
    }

    @Override
    public List<Charging> getChargingExportExcel(Charging charging) {
        List<Charging> submission = chargingMapper.getChargingExportExcel(charging);
        return submission;
    }
}
